<template>
<div class="content">
  <div class="popWindow" v-if="pop!=0">
    <em class="close" @click="pop=0"></em>
    <div class="infoBox">
      <div class="top">
        <div class="ktv">{{dataShowData.list[infoInow].ktv_name}}</div>
        <div class="ticket">
          <b v-html="dataShowData.list[infoInow].coup_name">6支啤酒免单券</b>
        </div>
        <div class="num">
          昵称<b>{{dataShowData.list[infoInow].nickname}}</b><br/>
          券号<b>{{dataShowData.list[infoInow].code}}</b>
        </div>
        <div class="date">{{dataShowData.list[infoInow].addtime}}抢到券日期<!--  {{dataShowData.list[infoInow].endtime}}到期--></div>
      </div>
      <div class="cont">
        <ul>
          <li><label>地址：</label><p>{{dataShowData.list[infoInow].address}}</p></li>
          <li><label>联系电话：</label><p>{{dataShowData.list[infoInow].tel}}</p></li>
        </ul>
        <div class="line"></div>
        <div class="text" v-html="dataShowData.list[infoInow].remark">
        </div>
      </div>
    </div>
  </div>
  <div class="explainPop" v-if="explainPop!=0">
    <div class="box">
      <em class="close" @click="explainPop=0">×</em>
      <h2>致歉信</h2>
      <p>5月14日晚上19:00抢券平台开启时，出现了重大数据异常。此次异常是由于我们软件开发方低估了抢券市民的热情一一抢券人数大大超过服务器承载能力，引起服务器宕机，造成数据紊乱，致使您的抢券超出了平台额定的数量。</p>
      <p>在此，我们向造成困扰与不便的抢票市民朋友致以最诚挚道歉，同时也向活动主办单位，各协办单位致以歉意。</p>
      <p>下一步，我们将进一步升级服务器，排查各类风险漏洞，加强事前事中监管，坚决防止抢券平台各类事故发生，不辜负广大市民朋友的热情和期待！</p>
      <p>微客网络</p>
      <p>2019年5月14日</p>
      <!--<button class="btnStyle btn2" @click="explainPopFn">不再显示</button>-->
    </div>
  </div>
  <ul class="list">
    <li v-for="(item,idx) in dataShowData.list" @click="infoFn(item.state,idx)" :class="{'end':item.state==1,'out':item.state==2,'out out2':item.state==-1}">
      <div class="cl">
        <div class="ktv">{{item.ktv_name}}</div>
        <div class="name" v-html="item.coup_name"></div>
      </div>
      <div class="cr">
        <div class="num" v-if="item.state!=-1">
          <p>券号{{item.state==-1?'-下周使用':''}}</p>
          <b>{{item.code}}</b>
        </div>
        <div class="date" v-if="item.state!=-1">{{item.endtime}}</div>
        <div class="info" v-if="item.state!=-1">查看详情</div>
        <div class="info" v-if="item.state==-1" @click="explainPop=1">查看详情</div>
      </div>
    </li>
  </ul>
</div>
</template>

<script>
export default{
  data:()=>{
    return{
      pop:0,
      dataShowData:'',
      infoInow:0,
      explainPop:0
    }
  },
  mounted(){
    this.dataShowFn();
  },
  methods:{
    explainPopFn(){
      localStorage.setItem('explainPop',0);
      this.explainPop=0;
    },
    infoFn(val,idx){
      if(val!=-1){
        this.pop=1;
        this.infoInow=idx;
      }
    },
    dataShowFn(){
      this.http(this.api.coupon_my).then(res=>{
        switch(parseInt(res.data.ret,10)){
          case 0:
            this.dataShowData=res.data.data;
            if(parseInt(localStorage.getItem('explainPop'))===0){
              return false;
            }
            this.dataShowData.list.forEach((item,i)=>{
              if(item.state==-1){
                this.explainPop=1;
                return false;
              }
            });
            break;
          default:
            Toast(res.data.msg);
        }
      });
    }
  }
}
</script>

<style lang="scss" type="text/scss" scoped>
.content{
  overflow:auto;
  display:block;
  padding:20px 0;
  .explainPop{
    position:fixed;
    z-index:3;
    background-color:rgba(#000,0.5);
    left:0;
    top:0;
    width:100%;
    height:100%;
    display:flex;
    .box{
      margin:auto;
      background-color:#FFF;
      width:80%;
      padding:30px;
      box-sizing:border-box;
      border-radius:10px;
      overflow:hidden;
      position:relative;
      .close{
        position:absolute;
        right:0;
        top:0;
        width:60px;
        line-height:60px;
        background-color:#EEE;
        font-size:50px;
        border-bottom-left-radius:10px;
      }
      h2{
        font-size:36px;
        font-weight:bold;
        padding-bottom:20px;
      }
      p{
        text-align:left;
        padding:10px 0;
        line-height:1.4;
      }
      .btn2{
        width:200px;
      }
    }
  }
  .infoBox{
    width:600px;
    height:1000px;
    margin:10% auto auto;
    background-image:url('~@img/discountBg.png');
    background-size:100% 100%;
    display:flex;
    flex-direction:column;
    .top{
      color:#ead6b8;
      height:494px;
      .ktv{
        font-size:40px;
        font-weight:bold;
        line-height:100px;
      }
      .ticket{
        margin:auto;
        width:363px;
        height:195px;
        background-image:url('~@img/discountListItem.png');
        background-size:100% 100%;
        display:flex;
        b{
          font-size:50px;
          margin:auto;
          color:#000;
          line-height:1.2;
          display:inline-block;
        }
      }
      .num{
        margin-top:16px;
        line-height:60px;
        font-size:30px;
        b{
          font-size:40px;
          padding-left:10px;
        }
      }
      .date{
        opacity:0.5;
      }
    }
    .cont{
      text-align:left;
      flex:1;
      margin:40px;
      overflow:auto;
      line-height:1.5;
      ul{
        font-size:26px;
        overflow:hidden;
        li{
          display:flex;
          margin-bottom:20px;
          label{
            width:5.5em;
            text-align:right;
          }
          p{
            flex:1;
          }
        }
      }
      .line{
        margin:20px auto;
        height:6px;
        background-color:#999;
        border-radius:999em;
        width:10%;
      }
      .text{
        overflow:hidden;
        margin-top:40px;
        font-size:22px;
        p{
          margin-bottom:20px;
          display:block;
        }
      }
    }
  }
  .list{
    li{
      width:689px;
      height:228px;
      margin:20px auto;
      background-image:url('~@img/discountList.png');
      background-size:100% 100%;
      display:flex;
      &.end{
        background-image:url('~@img/discountListEnd.png');
      }
      &.out{
        background-image:url('~@img/discountListOut.png');
      }
      .cl{
        margin:auto;
        width:363px;
        height:195px;
        background-image:url('~@img/discountListItem.png');
        background-size:100% 100%;
        display:flex;
        flex-direction:column;
        justify-content:space-around;
        align-items: center;
        box-sizing: border-box;
        padding:20px 0;
        position:relative;
        .ktv{
          font-size:30px;
        }
        .name{
          font-size:40px;
          font-weight:bold;
          line-height:1.2;
        }
      }
      .cr{
        width:290px;
        box-sizing: border-box;
        padding:30px;
        display:flex;
        flex-direction: column;
        justify-content:space-between;
        color:#ead6b8;
        text-align:left;
        .num{
          p{
            padding-bottom:10px;
            font-size:30px;
          }
          b{
            font-size:40px;
          }
        }
        .date{
          font-size:26px;
          opacity:0.4;
        }
      }
      &.end,&.out{
        .cl{
          &:before{
            right:0;
            bottom:0;
            content:'';
            position:absolute;
            width:126px;
            height:133px;
            background-size:100% 100%;
          }
        }
      }
      &.end{
        .cl{
          &:before{
            background-image:url('~@img/discountListEndIco.png');
          }
        }
      }
      &.out{
        .cl{
          &:before{
            background-image:url('~@img/discountListOutIco.png');
          }
        }
        &.out2{
          .cl{
            &:before{
              background-image:url('~@img/discountListOutIco2.png');
            }
          }
        }
        .cr{
          color:#FFF;
          opacity:0.5;
        }
      }
    }
  }
}
</style>
